import java.util.Scanner;

public class Test03 {
    //求一个整数，在内存当中存储时，二进制1的个数。
    public static int countOnes(int n) {
        int count = 0;
        while (n != 0) {
            count++;
            n = n & (n - 1);
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println("请输入一个整数：");
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            System.out.println(countOnes(n));
        }
    }
}
